import jsonp from 'common/js/jsonp'
import axios from 'axios'
import {commonParams, options} from './config'

export function getSingerList() {
    const url = 'https://c.y.qq.com/v8/fcg-bin/v8.fcg'
    const data = Object.assign({}, commonParams, {
        channel: 'singer',
        page: 'list',
        key: 'all_all_all',
        pagesize: 100,
        pagenum: 1,
        hostUin: 0,
        needNewCode: 0,
        platform: 'yqq',
        g_tk: 5831
    })
    return jsonp(url, data, options)
}

export function getSingerDetail(singerId) {
    const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg'
    const data = Object.assign({},commonParams,{
        hostUin: 0,
        needNewCode: 0,
        platform: 'yqq',
        order: 'listen',
        num: 100,
        songstatus: 1,
        singermid: singerId,
        g_tk: 5381
    })
    return jsonp(url, data, options)
}

export function getMusic (songmid) {
  const url = '/api/getMusic'
  const data = Object.assign({}, commonParams, {
    songmid: songmid,
    filename: `C400${songmid}.m4a`,
    guid: '6238879863',
    platform: 'yqq',
    loginUin: 0,
    g_tk: 5381,
    Uin: 0,
    cid: '205361747',
    format:'json'
  })
   return axios.get(url,{
    params: data
   }).then((res)=>{
    return Promise.resolve(res.data)
   })
}

